<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ include file="/pub/includ.jsp"%>
<script type="text/javascript">
	$(document).ready(function(){
	        $.formValidator.initConfig({formid:"portletform",alertmessage:false,onerror:function(msg){alert(msg)}});
			$("#artgroupId").formValidator().inputValidator({min:1,onerror:"必须选择一个文章分类"});
			$("#assoportlet").formValidator({empty:"true"}).inputValidator({min:0,max:50,onerror:"无效的PortletID"});
	        
	        $("#articlecount").formValidator().inputValidator({min:1,max:100,type:"value",onerror:"显示文章数量必须是1-100之间的数字"});
            $("#titlelength").formValidator().inputValidator({min:1,max:500,type:"value",onerror:"显示文章标题长度必须是1-500之间的数字"});
            $("#summarylength").formValidator().inputValidator({min:1,max:500,type:"value",onerror:"显示摘要长度必须是1-500之间的数字"});
            
            $("#title").formValidator({empty:"true"}).inputValidator({min:1,max:250,onerror:"portlet名称过长"});
            $("#portletwidth").formValidator().inputValidator({min:0,max:1500,type:"value",onerror:"portlet宽度必须是0-1500之间的数组"});
            $("#portletheight").formValidator().inputValidator ({min:0,max:5000,type:"value",onerror:"portlet高度必须是0-5000之间的数组"});
	});
	
	var save = function(){
		var flag = "failure";
		if($.formValidator.pageIsValid()){
			var options = {
				type: 'POST',
				async: false,
				dataType: 'content-type',
				success: function(msg) {
						flag = "success";
				}
			}
			$('#portletform').ajaxSubmit(options);
		}
		return flag;
	 }
	 
	function selchannel(oId,oName){
			$('<iframe src="<%=path %>/cms/article/get/selGrpIndex?oId='+oId+'&oName='+oName+'" />').dialog({
                title: '选择文章分组',
                autoOpen: true,
                width: 300,
                height: 200,
                modal: true,
	            buttons: {
					"确定": function() {
						var retv = this.contentWindow.getChannels();
						document.getElementById(oId).value=retv.split("$")[0];
						document.getElementById(oName).value=retv.split("$")[1];
						$(this).dialog( "close" );
					},
					"关闭": function() {
						$(this).dialog( "close" );
					}
				}  
            }).width(300).height(200);
	}
	
	function selectColor(){
            opendailog("{src:'<%=path %>/resources/component/farbtastic/demo1.jsp?color="+$('#titlecolor').val().substring(1,$('#titlecolor').val().length)+"',title:'选取颜色',width:320,height:300,savefunc:'savefunc1'}",window);
	}
	
	function savefunc1(frame,par){
		var retv = frame.contentWindow.save();
		$('#titlecolor').val(retv);
		return "success";
	}
	
	function selectImage(){
		opendailog("{src:'<%=path %>/res/get/selectImageIndex',title:'选取图片',width:600,height:400,savefunc:'savefunc2'}",window);
	}
	function savefunc2(frame){
		var retv = frame.contentWindow.save();
		if(retv){
			$('#titlepic').val(retv);
			return "success";		
		}
	}
</script>
<form id="portletform"  action="<%=path%>/cms/portlet/saveportlet" method="post" target="_self">
<table><tr><td height="2px"></td></tr></table>
<table align="center" border="0" cellpadding="0" cellspacing="1" class="table_nbw" >
	<thead class="th_nbw">
	<tr>
		<td colspan="2" align="center"><strong>文章展现形式设置 ${portlet.id}</strong></td>
	</tr>
	</thead>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">选择展示文章分类</td>
		<td align="left" style="background-color:fff">
			<input class="textfiled_nbw"  type="text"  readonly="readonly" id="showArtType" name="showArtType" value="${portlet.showArtType}">
			<input type="hidden" id="artgroupId" name="artgroupId" value="${portlet.artgroupId}">
			<input type="button" value="选择" onclick="selchannel('artgroupId','showArtType')"/>
		</td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">是否导航</td>
		<td align="left" style="background-color:fff">&nbsp;
			<input type="radio" value="0" checked="checked" name="isnavi" />否
			&nbsp;&nbsp;&nbsp;&nbsp; 
			<input type="radio" value="1" ${portlet.isnavi==1?'checked=checked':''} name="isnavi" />是
		</td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">导航展示层次</td>
		<td align="left" style="background-color:fff">&nbsp;
			<select name="showlevel" style="width:80">
				<option value="1" ${'1'==portlet.showlevel?'selected':''}>1</option>
				<option value="2" ${'2'==portlet.showlevel?'selected':''}>2</option>
				<option value="3" ${'3'==portlet.showlevel?'selected':''}>3</option>
				<option value="4" ${'4'==portlet.showlevel?'selected':''}>4</option>
			</select>
		</td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">关联文章portlet</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="assoportlet" name="assoportlet" value="${portlet.assoportlet}"></td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">显示文章数量</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="articlecount" name="articlecount" value="${portlet.articlecount}"></td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">展示文章标题长度</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="titlelength" name="titlelength" value="${portlet.titlelength}"></td>
	</tr>

	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">显示摘要长度</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="summarylength" name="summarylength" value="${portlet.summarylength}"></td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">显示模板</td>
		<td align="left" style="background-color:fff">&nbsp;
			<select name="templateid" style="width:120">
			<c:forEach var="template" items="${templateList}"> 
				<option value='${template.id}' ${template.id==portlet.templateid?'selected':''}>
					${template.name}
				</option> 
			</c:forEach> 
			</select>
		</td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">portlet名称</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="title" name="title" value="${portlet.title}"></td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">portlet名称展示类型</td>
		<td align="left" style="background-color:fff">&nbsp;
			<input type="radio" value="0" checked="checked" name="titletype" />样式
			&nbsp;&nbsp;&nbsp;&nbsp; 
			<input type="radio" value="1" ${portlet.titletype=="1"?'checked=checked':''} name="titletype" />图片
		</td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">portlet名称样式</td>
		<td align="left" style="background-color:fff">&nbsp;
			<select name="titlecolor" style="width:120">
				<option value='portal_title1' ${portlet.titlecolor=='portal_title1'?'selected':''}>标题1</option> 
				<option value='portal_title2' ${portlet.titlecolor=='portal_title2'?'selected':''}>标题2</option> 
				<option value='portal_title3' ${portlet.titlecolor=='portal_title3'?'selected':''}>标题3</option> 
				<option value='portal_title4' ${portlet.titlecolor=='portal_title4'?'selected':''}>标题4</option> 
				<option value='portal_title5' ${portlet.titlecolor=='portal_title5'?'selected':''}>标题5</option> 
				<option value='portal_title6' ${portlet.titlecolor=='portal_title6'?'selected':''}>标题6</option> 
			</select>
		</td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">portlet名称图片</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="titlepic" name="titlepic" value="${portlet.titlepic}">
			<input type = "button"  value = "选择"  onclick = "selectImage();">
		</td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">portlet长度</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="portletwidth" name="portletwidth" value="${portlet.portletwidth}"></td>
	</tr>
	<tr >
		<td align="right" width="40%"  style="background-color:fff;height:25px;">portlet高度</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="portletheight" name="portletheight" value="${portlet.portletheight}"></td>
	</tr>
</table>
<input type="hidden" id="showstate" name="showstate" value="1">
<input type="hidden" id="portletype" name="portletype" value="article">
<input type=hidden name="id" value="${portlet.id}" />
<input type="hidden" name="horderChannelId" value="${param.horderChannelId}"/>
<input type="hidden" name="placeholderId" value="${param.placeholderId}"/>
</form>


